package org.bot.server.log.controller;

import com.alibaba.fastjson.JSONObject;
import org.bot.server.log.service.BotClientLogService;
import org.bot.server.utils.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author 沧月
 * @create 0020 2023/10/20 10:37
 * @description <description class purpose>
 */

@RestController
@RequestMapping("/bot-log")
public class BotClientLogController extends BaseController {

    @Autowired
    BotClientLogService botClientLogService;

    @RequestMapping("/logList")
    public JSONObject logList(Integer flowId, Integer page, Integer size) {
        List<Map<String, Object>> log = botClientLogService.getLog(flowId, page, size);
        int count = botClientLogService.listCount(flowId);
        return sendData(new JSONObject().fluentPut("data",log).fluentPut("count",count));
    }

    @RequestMapping("/logInfoList")
    public JSONObject logInfoList(String logId) {
        return sendData(botClientLogService.getLogInfo(logId));
    }

    @RequestMapping("/flowList")
    public JSONObject flowList(Integer clientId) {
        return sendData(botClientLogService.flowList(clientId));
    }
}
